<%@ page contentType="text/html;charset=UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>手机号码归属信息管理系统 </title>
<link href="./css/style.css" type="text/css" rel="stylesheet" />
<script src="./js/jquery.js" type="text/javascript"></script>
<style type="text/css">
 body{
	background-image: url("./img/login.jpg");
	background-position:top;
	background-repeat:no-repeat;
	background-color: #0657b0;
	TEXT-ALIGN: center;
}
#loignDiv{
	MARGIN-RIGHT: auto; 
	MARGIN-LEFT: auto;
	top:-4px;
	position: relative;
}

/**
* 用span占位的样式
*/
.spanLetterSpacing{
    display:-moz-inline-box;
    display:inline-block;
    width:170px;
    vertical-align:top;
}
/**
* 用span占位的样式
*/
.spanLetterSpacing1{
    display:-moz-inline-box;
    display:inline-block;
    width:30px;
    vertical-align:top;
}
/**
* 用span占位的样式
*/
.spanLetterSpacing2{
    display:-moz-inline-box;
    display:inline-block;
    width:88px;
    vertical-align:top;
}
/**
* 用span占位的样式
*/
.btn{
    display:-moz-inline-box;
    display:inline-block;
    width:135px;
    vertical-align:top;
    height: 45px;
}
</style>
</head>

<body >
	<div id="loignDiv">
		<div style="position: relative;margin-top:288px;">
			<span class="spanLetterSpacing"></span>
			<input type="text" id="usernumber" name="usernumber" style="height:24px;width:220px;border-color:#c6e0f1;">
		</div>
		<div style="position: relative;margin-top:30px;">
			<span class="spanLetterSpacing"></span>
			<input type="password" id="password" name="password" style="height:24px;width:220px;border-color:#c6e0f1;">
		</div>
		<div style="position: relative;margin-top:30px;">
			<span class="spanLetterSpacing1"></span>
			<span class="btn"  id="loginBtn"></span>
			<span class="spanLetterSpacing2"></span>
			<span class="btn" id="clear"></span>
		</div>
	</div>
</body>
</html>

<script>
	$(function(){
		$("#loginBtn").click(function(){
			if(checkEmpty()){
				login();
			}
		});
		
		$("#clear").click(function(){
			$("#usernumber").val("");
			$("#password").val("");
		});
	})
	
	
	function onLogin(){
		if(checkEmpty()){
			login();
		}
	}
	
	function checkEmpty(){
		if($("#usernumber").val() == "" || $("#usernumber").val() == null){
			alert("用户名不能为空");
			$("#usernumber").focus();
			return false;
		}
		if($("#password").val() == "" || $("#password").val() == null){
			alert("密码不能为空");
			$("#password").focus();
			return false;
		}
		return true;
	}
	
	function login(){
		$.ajax({
            url: "/survey/rest/login/loginByUserNumberAndPassword",
            type: "GET",
            data: {
           	 	usernumber:$("#usernumber").val(),
           	 	password:$("#password").val()
            },
            dataType: 'json',
            success: function(result, status){
				if(result == null) {
	         		alert("用户名或密码错误!");
	         	 } else {
					window.location.href = "./index.jsp";
	         	 }
            },
            error: function(){
				alert("登陆失败!");
            }
        });
	}
</script>